import RPi.GPIO as GPIO
import time
 
LEFT_LED =  14 # pin 8
RIGHT_LED  = 21 # pin 40

# 设置编码方式
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)

# 设置引脚
GPIO.setup(LEFT_LED , GPIO.OUT)
GPIO.setup(RIGHT_LED , GPIO.OUT)
 
# 引脚输出一个高电平，灯亮; 引脚输出一个低电平，灯灭
try:
    while True:
        GPIO.output(LEFT_LED, GPIO.HIGH)
        GPIO.output(RIGHT_LED , GPIO.LOW)
         # 等1秒
        time.sleep(1)
        GPIO.output(LEFT_LED, GPIO.LOW)
        GPIO.output(RIGHT_LED , GPIO.HIGH)
        # 等1秒
        time.sleep(1)
except KeyboardInterrupt: # Ctrl+C
    # 使用结束，释放引脚
    GPIO.cleanup()


